<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="icon" href="../../logo.svg" />
    <title>基本列表</title>
  </head>
  <body>
    <div id="root">
      <h2>人员列表</h2>
      <ul>
        <li v-for="(p,idx) in persons" :key="p.id">
          <!-- {{idx}}: {{p.name}} - {{p.age}} -->
          <div>#{{idx}}</div>
          <div v-for="(v,k) in p">{{k}}: {{v}}</div>
        </li>
      </ul>

      <h2>遍历字符串</h2>
      <ul>
        <li v-for="(char,idx) in msg" :key="idx">#{{idx}} - {{char}}</li>
      </ul>

      <h2>遍历指定次数</h2>
      <ul>
        <li v-for="(n,idx) in 5" :key="idx">#{{idx}} - {{n}}</li>
      </ul>
    </div>

    <script src="../../vue.js"></script>
    <script>
      Vue.config.productionTip = false; // 阻止 vue 在启动时生成生产提示。

      new Vue({
        el: "#root",
        data: {
          persons: [
            { id: 1, name: "张三", age: 12 },
            { id: 2, name: "李四", age: 19 },
            { id: 3, name: "王五", age: 20 },
          ],
          msg: "Hello世界",
        },
      });
    </script>
  </body>
</html>
